<?php
class StoreOrder extends StoreAppModel {
	var $name = 'StoreOrder';
	var $displayField = 'id';
	var $validate = array(
		'user_id' => array(
			'numeric' => array(
				'rule' => array('numeric'),
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'delivery_name' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'The field can not be empty',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			)
		),
		'delivery_surname' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'The field can not be empty',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			)
		),
		'delivery_address1' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'The field can not be empty',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			)
		),
		'delivery_address3' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'The field can not be empty',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			)
		),
		'delivery_address4' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'The field can not be empty',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			)
		),
		'delivery_address5' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'The field can not be empty',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			)
		)
	);
	//The Associations below have been created with all possible keys, those that are not needed can be removed

	var $hasMany = array(
	'StoreOrderDetail' =>
		array( 	'className' => 'StoreOrderDetail',
				'foreignKey' => 'order_id',
				'unique' => true
			 ),
	'StoreOrderDelivery' =>
		array( 	'className' => 'StoreOrderDelivery',
				'foreignKey' => 'order_id',
				'unique' => true
			 )			 
	);
	
	var $hasAndBelongsToMany = array(
	'StoreProduct' =>
		array( 	'className' => 'StoreProduct',
				'joinTable' => 'store_order_detail',
				'foreignKey' => 'order_id',
				'associationForeignKey' => 'product_id',
				'unique' => true
			 ),
	'StoreType' =>
		array( 	'className' => 'StoreType',
				'joinTable' => 'store_order_detail',
				'foreignKey' => 'order_id',
				'associationForeignKey' => 'type_id',
				'unique' => true
			 ) 
	);
	
	var $belongsTo = array(
		'User' => array(
			'className' => 'User',
			'foreignKey' => 'user_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		)
	);
}
?>